package com.atde._04_structural_design_patterns.adapter.objectadapter;


/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._04_structural_design_patterns.adapter.objectadapter
 * @Author: Del
 * @CreateTime: 2025-06-18  20:32
 * @Description: 适配器模式 --- 对象适配器 --- 适配器类
 * @Version: 1.0
 */
public class VoltageAdapter implements IVoltage5V {
    // 适配器类进行聚合
    private Voltage220V voltage220V;

    // 通过构造器，传入一个Voltage220V 的实例
    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    public void setVoltage220V(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int output5V() {
       int dst = 0;
       if (voltage220V != null) {
           dst = voltage220V.output220V() / 44;
           System.out.println("使用对象适配器，进行适配");
           System.out.println("适配器类输出电压：" + dst);
       }
       return dst;
    }
}
